package hibernate.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

@SuppressWarnings("serial")
@Entity
@Table(name = "kullanici", catalog = "emmy", uniqueConstraints = @UniqueConstraint(columnNames = "kullaniciAdi"))
@NamedQueries({
@NamedQuery(name = "findKlcKulAdi", query = "from Kullanici where kullaniciAdi = :kKulAdi"),
@NamedQuery(name = "findKlcPass", 	query = "from Kullanici where parola = :kParola"),
@NamedQuery(name = "findKlcGrup",   query = "from Kullanici where grup = :kGrup")
})
public class Kullanici implements java.io.Serializable {

	private Long kullaniciid;
	private String kullaniciAdi;
	private String parola;
	private int grup;
	private Musteri musteri;
	private Temsilci temsilci;

	public Kullanici() {
	}

	public Kullanici(String kullaniciAdi, String parola, int grup) {
		this.kullaniciAdi = kullaniciAdi;
		this.parola = parola;
		this.grup = grup;
	}

	public Kullanici(String kullaniciAdi, String parola, int grup,
			Musteri musteri, Temsilci temsilci) {
		this.kullaniciAdi = kullaniciAdi;
		this.parola = parola;
		this.grup = grup;
		this.musteri = musteri;
		this.temsilci = temsilci;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "kullaniciid", unique = true, nullable = false)
	public Long getKullaniciid() {
		return this.kullaniciid;
	}

	public void setKullaniciid(Long kullaniciid) {
		this.kullaniciid = kullaniciid;
	}

	@Column(name = "kullaniciAdi", unique = true, nullable = false, length = 30)
	public String getKullaniciAdi() {
		return this.kullaniciAdi;
	}

	public void setKullaniciAdi(String kullaniciAdi) {
		this.kullaniciAdi = kullaniciAdi;
	}

	@Column(name = "parola", nullable = false, length = 20)
	public String getParola() {
		return this.parola;
	}

	public void setParola(String parola) {
		this.parola = parola;
	}

	@Column(name = "grup", nullable = false)
	public int getGrup() {
		return this.grup;
	}

	public void setGrup(int grup) {
		this.grup = grup;
	}

	@OneToOne(fetch = FetchType.EAGER, mappedBy = "kullanici", cascade = CascadeType.REMOVE)
	public Musteri getMusteri() {
		return this.musteri;
	}

	public void setMusteri(Musteri musteri) {
		this.musteri = musteri;
	}

	@OneToOne(fetch = FetchType.EAGER, mappedBy = "kullanici", cascade = CascadeType.REMOVE)
	public Temsilci getTemsilci() {
		return this.temsilci;
	}

	public void setTemsilci(Temsilci temsilci) {
		this.temsilci = temsilci;
	}
}